{layout name="layout/main" /}

<blockquote class="layui-elem-quote quoteBox">
    <form class="layui-form">
        <div class="layui-inline">
            <div class="layui-input-inline">
                <input name="truename" type="text" class="layui-input" placeholder="请输入搜索的内容"/>
            </div>
            <a class="layui-btn search_btn" lay-submit lay-filter="tablelistReload" id="tablelistReload">搜索</a>
        </div>
    </form>
</blockquote>

<div id="boxTableNone">
    <script type="text/html" id="tplToolbar">
        <div class="layui-btn-container"></div>
    </script>
    <!-- 是否阅读 -->
    <script type="text/html" id="statusHtml">
        {{#  if(d.status === 0){ }}
        <span class="layui-btn layui-btn-xs layui-btn-danger" lay-active="resubmitStatus" data-id="{{d.id}}" data-title="{{d.status}}">未读</span>
        {{#  } else if(d.status === 1) { }}
        <span>已读</span>
        {{#  } else { }}
        <span>其它</span>
        {{#  } }}
    </script>
    <script type="text/html" id="toolbarHtml">

        <a class="layui-btn layui-btn-xs" lay-event="detail">详情</a>
    </script>

    <table class="layui-hide layui-table x-admin" id="tablelist" lay-filter="tablelist"></table>
</div>

<script type="text/javascript" src="/static/vfs/tablelistobj.js"></script>
<script>
    layui.use(['form', 'table', 'jquery', 'layer', 'util'], function () {
        var table = layui.table;
        var form = layui.form;
        var layer = layui.layer;
        var util = layui.util;
        var $ = layui.jquery;
        //渲染列表
        tablelistobj.$ = $;
        tablelistobj.tool_obj = {
            lists : {href: "{:url('admin/feedback/lists')}", title: '列表'},
            detail : {href: "{:url('admin/feedback/detail')}", title: '详情'},
        };
        tablelistobj.cols = [[
            {field: 'id', type: 'checkbox', width: 80},
            {field: 'id', width: 80, title: 'ID', sort: true},
            {field: 'truename', title: '反馈人'},
            {field: 'mobile', title: '反馈人电话'},
            {field: 'status', title: '状态', width: 100, templet: '#statusHtml', unresize: true},
            {field: '', title: '操作', align: 'center', toolbar: '#toolbarHtml', width: 150}
        ]];
        tablelistobj.render(table);
        //搜索表单
        tablelistobj.search(table, form);
        //操作按钮
        tablelistobj.form_width = 1000;
        tablelistobj.form_height = 450;
        tablelistobj.tool(table, layer);
        //头工具栏事件
        tablelistobj.toolbar(table, layer);
        util.event('lay-active', {
            resubmitStatus: function () {
                var id = $(this).data('id');
                layer.confirm('确定标记为已读吗？', {
                    btn: ['确定', '取消'],
                }, function () {
                    var postData = {type: 'status0', id: id};
                    $.post("{:url('admin/feedback/updateColumn')}", postData, function (res) {
                        var message = res.message;
                        if (res.code == 0) {
                            layer.msg(message, {icon: 1, time: 2000});
                            table.reload(tablelistobj.filter, {
                                method: 'post',
                                page: {curr: 1},
                            });
                        } else {
                            layer.msg(message, {icon: 2, time: 2000});
                        }
                    }, 'json');
                });
            },
            statusRemarks : function(){
                var that = $(this);
                var tips = that.data('title');
                layer.tips(tips, that, {tips: 1});
            },
        });
    });
</script>